package org.example.domain;

import java.util.ArrayList;
import java.util.List;

public class DemoExample {
    protected String orderByClause;
    protected boolean distinct;
    protected List<Criteria> oredCriteria;

    public DemoExample() {
        oredCriteria = new ArrayList<>();  
    }  

    // getter 和 setter 方法  
    public void setOrderByClause(String orderByClause) {  
        this.orderByClause = orderByClause;  
    }  

    public String getOrderByClause() {  
        return orderByClause;  
    }  

    public void setDistinct(boolean distinct) {  
        this.distinct = distinct;  
    }  

    public boolean isDistinct() {  
        return distinct;  
    }  

    public List<Criteria> getOredCriteria() {  
        return oredCriteria;  
    }  

    public void or(Criteria criteria) {  
        oredCriteria.add(criteria);  
    }  

    public Criteria createCriteria() {  
        Criteria criteria = createCriteriaInternal();  
        oredCriteria.add(criteria);  
        return criteria;  
    }  

    protected Criteria createCriteriaInternal() {  
        Criteria criteria = new Criteria();  
        return criteria;  
    }  

    public void clear() {  
        oredCriteria.clear();  
        orderByClause = null;  
        distinct = false;  
    }  


    public static class Criteria {  
        protected List<Criterion> criteria;  

        protected Criteria() {  
            super();  
            criteria = new ArrayList<>();  
        }  

        // 条件判断与构建方法  
        public boolean isValid() {  
            return !criteria.isEmpty();  
        }  

        // andNameLike 方法（核心模糊查询方法）  
        public Criteria andNameLike(String value) {  
            addCriterion("name like", value, "name");  
            return this;  
        }  

        // 其他字段的条件方法（如 id、category1Id 等）  
        public Criteria andIdEqualTo(Long value) {  
            addCriterion("id =", value, "id");  
            return this;  
        }  

        // 底层条件构造方法  
        protected void addCriterion(String condition, Object value, String property) {  
            if (value == null) {  
                throw new RuntimeException("Value for " + property + " cannot be null");  
            }  
            criteria.add(new Criterion(condition, value));  
        }  

        // 其他辅助方法...  
    }  


    public static class Criterion {  
        private String condition;  
        private Object value;  
        private Object secondValue;  
        private boolean noValue;  
        private boolean singleValue;  
        private boolean betweenValue;  
        private boolean listValue;  

        // 构造方法与 getter 方法...  
        public Criterion(String condition, Object value) {  
            this.condition = condition;  
            this.value = value;  
            this.singleValue = true;  
        }  
    }  
}